The rail network in the Algarve ends at Lagos, so Salema is inaccessible by train. It's just off the N125 route from Lagos, and quite accessible by car though parking may be an issue during busy months. You can also take the bus from Lagos for a handful of Euros. Hiking from Lagos is also an option for the determined backpacker, using a combination of beach trails and roads, but the distance is rather long just under 20km.